package org.chipu.jnids.sce.profile;

import java.util.Collection;
import java.util.HashSet;
import org.junit.Assert;
import org.junit.Test;

public class StatsTester {
	public void efficiency() {
		int[] ns = {1, 3, 5, 7, 9, 11};
		Collection<Integer> c = new HashSet<Integer>();
		for(int i : ns)
			c.add(i);
		// Using collection is the slowest, for the array, is better using classic for loops
	}

	@Test
	public void createEmptyStats() {
		Assert.assertNull(Stats.getStats());
	}

	@Test
	public void createStatsWithNegativeValue() {
		Stats s = Stats.getStats(4, -2, 7);
		Assert.assertEquals(3, s.dataCount);
		Assert.assertEquals(3f, s.average, 0.00000000001);
		// on unix: 0.00000000001, on windows: 0.000001
		Assert.assertEquals(3.7416573867739413, s.standardDeviation, 0.000001);
	}

	@Test
	public void createStats() {
		Stats s = Stats.getStats(5, 4);
		Assert.assertEquals(2, s.dataCount);
		Assert.assertEquals(4.5, s.average, 0.00000000001);
		Assert.assertEquals(0.5, s.standardDeviation, 0.00000000001);
	}
}